<template>
  <div class="about">
    <!-- <h1 @click="sumOrderMoney">日期区间业绩</h1> -->
    <el-date-picker
      v-model="duration"
      type="daterange"
      range-separator="-"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
      value-format="yyyy-MM-dd"
    >
    </el-date-picker>
    <el-button type="primary" @click="sumOrderMoney">点击查询销售额</el-button>
    总销售额：￥{{ sum }}

    <h1 @click="getEndTimeOrder">以下订单将在7天后到期</h1>
    <!-- {{ orders }} -->
  </div>
</template>

<script>
// @ is an alias to /src

export default {
  name: "Home",
  data: function () {
    return {
      orders: "",
      duration: ["2000-01-01", "2022-01-1"],
      sum: 0,
    };
  },
  components: {},
  methods: {
    sumOrderMoney() {
      let _this = this;
      this.$axios({
        url: "/order/sumOrderMoney",
        method: "get",
        params: { start: _this.duration[0], end: _this.duration[1] },
      }).then(function (resp) {
        _this.sum = resp.data;
      });
    },
    getEndTimeOrder() {
      let now = new Date();
      let time = new Date(now.getTime() - 604800000);
      let _this = this;
      this.$axios({
        url: "/order/getEndTimeOrder",
        method: "get",
        params: { start: time, end: now },
      }).then(function (resp) {
        _this.orders = resp.data;
      });
    },
  },
};
</script>